using System;
using System.Collections.Generic;
using System.Text;

using SD.LLBLGen.Pro.ORMSupportClasses;
using DatabaseAdapter;
using DatabaseGeneric;
using DatabaseGeneric.FactoryClasses;
using DatabaseGeneric.EntityClasses;
using DatabaseGeneric.RelationClasses;
using DatabaseGeneric.HelperClasses;

namespace Services
{
    public class ChungLoaiSanPham : Interfaces.IChungLoaiSanPham
    {
        public EntityCollection<ChungLoaiSanPhamEntity> FetchCollection()
        {
            EntityCollection<ChungLoaiSanPhamEntity> collectionChungLoaiSanPham = new EntityCollection<ChungLoaiSanPhamEntity>();
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchEntityCollection(collectionChungLoaiSanPham, null);
            }
            return collectionChungLoaiSanPham;
        }

        public ChungLoaiSanPhamEntity FetchEntity(ChungLoaiSanPhamEntity currentEntityChungLoaiSanPham)
        {
            ChungLoaiSanPhamEntity entityChungLoaiSanPham = new ChungLoaiSanPhamEntity(currentEntityChungLoaiSanPham.MaChungLoaiSanPham);
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchEntity(entityChungLoaiSanPham);
            }
            return entityChungLoaiSanPham;
        }

        public int SaveCollection(EntityCollection<ChungLoaiSanPhamEntity> currentCollectionChungLoaiSanPham)
        {
            int cntSave = 0;
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                cntSave = adapter.SaveEntityCollection(currentCollectionChungLoaiSanPham);
            }
            return cntSave;
        }

        public bool SaveEntity(ChungLoaiSanPhamEntity currentEntityChungLoaiSanPham)
        {
            bool isSave = false;
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                isSave = adapter.SaveEntity(currentEntityChungLoaiSanPham);
            }
            return isSave;
        }

        public int DeleteCollection(EntityCollection<ChungLoaiSanPhamEntity> currentCollectionChungLoaiSanPham)
        {
            int cntDelete = 0;
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.DeleteEntityCollection(currentCollectionChungLoaiSanPham);
            }
            return cntDelete;
        }

        public bool DeleteEntity(ChungLoaiSanPhamEntity currentEntityChungLoaiSanPham)
        {
            bool isDelete = false;
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                isDelete = adapter.DeleteEntity(currentEntityChungLoaiSanPham);
            }
            return isDelete;
        }

        public System.Data.DataTable Report()
        {
            System.Data.DataTable dtChungLoaiSanPham = new System.Data.DataTable();
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                dtChungLoaiSanPham = RetrievalProcedures.ChungLoaiSanPhamPro(adapter);
            }
            return dtChungLoaiSanPham;
        }
    }
}
